package main

import (
	"flag"
	"fmt"
	"math/rand"
	"os/user"
	"runtime"
	"study/common"
	"time"
)

var c bool = true

const author = "liufofu"

func main() {
	cfg := flag.String("c", "cfg.json", "configuration file")
	fmt.Println("configuration")
	fmt.Println(*cfg)
	a := []int{0, 0, 0}
	a[1] = 10
	x := "Hello,Golang~"
	if c == true {
		fmt.Println("c is true.")
	}
	for i := 0; i < len(x); i++ {
		fmt.Printf("%c,", x[i])
	}
	fmt.Println()
	fmt.Println(runtime.GOOS)
	user, err := user.Current()
	if nil == err {
		fmt.Println(user.HomeDir)
	}
	n := len(x)
	fmt.Println(n)
	for n > 0 {
		fmt.Printf("%c,", x[n-1])
		n--
	}
	fmt.Println()

	s := []int{1, 2, 3, 4, 5}
	for i, v := range s {
		if i == 0 {
			s = s[:3]
			s[2] = 200
		}
		fmt.Println(i, v)
	}

	for _, v := range s {
		fmt.Println(v)
	}

	m := map[string]int{"a": 1, "b": 10}
	for k, v := range m {
		fmt.Println(k, v)
	}

	fmt.Println("Hello,Golang~")
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	for i := 0; i < 100; i++ {

		if i%10 == 0 {
			fmt.Println()
		}
		fmt.Printf("%d,", r.Intn(10000))
	}
	fmt.Println()
	fmt.Println(common.Ff_genrandstr(5, 20))
	fmt.Println(common.Add(-1, 150))
	var f string = "/root/workspace/src/study/main.go"

	if common.IsFileExists(f) {
		fmt.Printf("%s is exists~~\n", f)
	} else {
		fmt.Printf("%s is not exists~~\n", f)
	}

	fmt.Println(author)
	fmt.Println(common.Factorial(10))

	fmt.Println(time.Now().Weekday())

	//	common.Ff_input()

}
